<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java单元测试生成器</title>
    <link rel="stylesheet" href="/static/css/style.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
</head>
<body>
    <div class="container">
        <header>
            <h1><i class="fas fa-code"></i> Java单元测试生成器</h1>
            <p class="subtitle">基于AI的Java代码单元测试自动生成工具</p>
        </header>

        <main>
            <div class="input-section">
                <h2><i class="fas fa-edit"></i> 输入Java代码</h2>
                <div class="form-group">
                    <label for="classPath">类路径：</label>
                    <input type="text" id="classPath" class="form-control" placeholder="例如: com.example.service.UserService" required>
                </div>
                <div class="form-group">
                    <label for="methodCode">方法代码：</label>
                    <textarea id="methodCode" class="form-control" placeholder="请输入需要生成测试的方法代码..." required></textarea>
                </div>
                <div class="button-container">
                    <button id="generateBtn" class="btn btn-primary">
                        <i class="fas fa-magic"></i> 生成测试代码
                    </button>
                </div>
            </div>

            <div class="output-section">
                <h2><i class="fas fa-file-code"></i> 生成的测试代码</h2>
                <div id="outputContainer">
                    <div id="emptyState" class="empty-state">
                        <i class="fas fa-robot"></i>
                        <h3>AI生成的测试代码将在这里显示</h3>
                        <p>输入Java代码后点击"生成测试代码"按钮</p>
                    </div>
                    <div id="loadingState" class="loading-state" style="display: none;">
                        <div class="loading-spinner"></div>
                        <p>正在生成测试代码...</p>
                    </div>
                    <div id="resultState" class="result-state" style="display: none;">
                        <div class="code-header">
                            <span class="file-name">GeneratedTest.java</span>
                            <button id="downloadBtn" class="btn btn-secondary">
                                <i class="fas fa-download"></i> 下载
                            </button>
                        </div>
                        <pre><code id="generatedCode" class="language-java"></code></pre>
                    </div>
                    <div id="errorState" class="error-state" style="display: none;">
                        <i class="fas fa-exclamation-triangle"></i>
                        <h3>生成失败</h3>
                        <p id="errorMessage"></p>
                    </div>
                </div>
            </div>
        </main>

        <footer>
            <p>&copy; 2025 Java单元测试生成器 | 基于AI的自动化测试工具</p>
        </footer>
    </div>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-java.min.js"></script>
    <script src="/static/js/app.js"></script>
</body>
</html>